package robottest;

import java.awt.AWTException;
import java.awt.Color;
import java.awt.MouseInfo;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.io.IOException;

public class RobotColorClick 
{

    public RobotColorClick () throws AWTException, IOException, InterruptedException 
    {
        Robot robot = new Robot();

        //Delay 5 seconds
        robot.delay(5000);        

        //Gets color (value of red,green,blue) from the mouse position after 5 seconds 
        Color color = robot.getPixelColor( MouseInfo.getPointerInfo().getLocation().x 
                , MouseInfo.getPointerInfo().getLocation().y);

        //Delay 3 seconds
        robot.delay(3000);

        //Mouse moves to X and Y then right click
        //Problem! How to set X and Y to position color coordinates, position will change
        //robot.mouseMove(x, y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        System.out.println("Color"+ color);

    }


    public static void main(String[] args) throws AWTException, IOException, 
                InterruptedException 
    {
        new RobotColorClick ();
    }
}